package apiday08.reflect;

import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.Scanner;

public class ReflectDemo1 {
    public static void main(String[] args) {
//        Class cls = String.class;
//        Class cls = ArrayList.class;

        Scanner sc = new Scanner(System.in);
        System.out.println("请输入类的完全限定名！");
        String str = sc.nextLine();
        Class cls = null;
        try {
            cls = Class.forName(str);
        } catch (ClassNotFoundException e) {
            e.printStackTrace();
        }

        System.out.println(cls);
        str = cls.getName();
        System.out.println(str);
        str = cls.getSimpleName();
        System.out.println(str);

        Package pack = cls.getPackage();
        System.out.println(pack);
        str = pack.getName();
        System.out.println(str);

        Method[] methods = cls.getMethods();
        System.out.println(cls.getSimpleName()+"类有"+methods.length+"个方法");
        for (Method m:methods){
            System.out.println(m.getName());
        }
        sc.close();
    }
}
